package com.ysb.util;

import java.io.Serializable;
import java.util.List;

public class Page <T> implements Serializable{
	private static final long serialVersionUID = 1L;
	private List<T> record;
	private int total;
	private int pn;
	private int psize;
	private boolean hasNext;
	private boolean hasPrev;
	private int nextPn;
	private int prevPn;
	
	public Page() {}

	public Page(List<T> record, int total, int pn, int psize) {
		this.record = record;
		this.total = total;
		this.pn = pn;
		this.psize = psize;
		this.hasNext = total > pn*psize;
		this.hasPrev = this.pn >1;
		this.nextPn = this.hasNext ? (this.pn+1):0;
		this.prevPn = this.hasPrev ? (this.pn-1):0;
	}

	public int getNextPn() {
		return nextPn;
	}

	public int getPrevPn() {
		return prevPn;
	}

	public List<T> getRecord() {
		return record;
	}

	public int getTotal() {
		return total;
	}

	public int getPn() {
		return pn;
	}

	public int getPsize() {
		return psize;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public boolean isHasPrev() {
		return hasPrev;
	}
	
	
}
